package com.magenta.maxoptra.gis;

/**
 * GGeoStatusCode Enum class
 * http://www.google.com/apis/maps/documentation/reference.html#GGeoStatusCode
 *
 * @author jliang
 */
public enum GeoStatusCode {
    G_GEO_UNKOWN_STATUS(-1, "<unknown-status>"),
    //Used by simulate service.
    G_GEO_RESULT_IS_NULL(-2, "<result-not-found>"),
    G_GEO_ABORTED_REQUEST(-3, "<aborted-request>"),
    G_GEO_SUCCESS(-4, "<success-result>"),
    G_GEO_BAD_REQUEST(-5, "<bad-request>"),
    G_GEO_SERVER_ERROR(-6, "<server-error>"),
    G_GEO_MISSING_QUERY(-7, "<missing-query>"),
    G_GEO_UNKNOWN_ADDRESS(-8, "<unknown-address>"),
    G_GEO_UNAVAILABLE_ADDRESS(-9, "<unavailable-address>"),
    G_GEO_UNKNOWN_DIRECTIONS(-10, "<unknown-directions>"),
    G_GEO_BAD_KEY(-11, "<bad-key>"),
    G_GEO_TOO_MANY_QUERIES(-12, "<geo-too-many-queries>"),
    G_GEO_BAD_START_POINT(-13, "<bad-start-point>"),
    G_GEO_BAD_INTERMEDIATE_POINT(-14, "<bad-intermediate-point>"),
    G_GEO_BAD_FINISH_POINT(-15, "<bad-finish-point"),
    G_GEO_ISOLATED_FINISH_POINT(-16, "<isolated-finish-point"),
    G_GEO_ISOLATED_INTERMEDIATE_POINT(-17, "<isolated-intermediate-point"),
    G_GEO_ISOLATED_START_POINT(-18, "<isolated-start-point");

    private String _description;
    private int _code;

    private GeoStatusCode(int code, String description) {
        _code = code;
        _description = description;
    }

    public int getCode() {
        return _code;
    }

    public String getCodeName() {
        return this.name();
    }

    public String getDescription() {
        return _description;
    }

    /**
     * Retrun the corresponding GGeoStatusCode based from the input code.
     */
    public static GeoStatusCode getStatusCode(int code) {
        switch (code) {
            case -1:return G_GEO_UNKOWN_STATUS;
            case -2:return G_GEO_RESULT_IS_NULL;
            case -3:return G_GEO_ABORTED_REQUEST;
            case -4:return G_GEO_SUCCESS;
            case -5:return G_GEO_BAD_REQUEST;
            case -6:return G_GEO_SERVER_ERROR;
            case -7:return G_GEO_MISSING_QUERY;
            case -8:return G_GEO_UNKNOWN_ADDRESS;
            case -9:return G_GEO_UNAVAILABLE_ADDRESS;
            case -10:return G_GEO_UNKNOWN_DIRECTIONS;
            case -11:return G_GEO_BAD_KEY;
            case -12:return G_GEO_TOO_MANY_QUERIES;
            case -13:return G_GEO_BAD_START_POINT;
            case -14:return G_GEO_BAD_INTERMEDIATE_POINT;
            case -15:return G_GEO_BAD_FINISH_POINT;
            case -16:return G_GEO_ISOLATED_FINISH_POINT;
            case -17:return G_GEO_ISOLATED_INTERMEDIATE_POINT;
            case -18:return G_GEO_ISOLATED_START_POINT;
            default: return G_GEO_UNKOWN_STATUS;
        }
    }
}